package com.kuang.demo.service;

import com.kuang.demo.bo.gh.ExpressConfigBO;
import com.kuang.demo.bo.gh.MallConfigBO;
import com.kuang.demo.bo.gh.OrderConfigBO;
import com.kuang.demo.bo.gh.WxConfigBO;
import com.kuang.demo.mapper.ConfigMapper;
import com.kuang.demo.vo.QueryOrderConfigVO;
import com.kuang.demo.vo.QueryExpressConfigVO;
import com.kuang.demo.vo.QueryMallConfigVO;
import com.kuang.demo.vo.QueryWxConfigVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 郭浩 on 2020/11/3 19:41
 */
@Service
public class ConfigServiceImpl implements ConfigService {

    @Autowired
    ConfigMapper configMapper;

    @Override
    public void mallConfig(MallConfigBO mallConfigBO) {
        if (!("").equals(mallConfigBO.getCskaoyanmall_mall_name()) && mallConfigBO.getCskaoyanmall_mall_name()!=null){
            configMapper.update_cskaoyan_mall_mall_name(mallConfigBO);
        }
        if (!("").equals(mallConfigBO.getCskaoyanmall_mall_qq()) && mallConfigBO.getCskaoyanmall_mall_qq()!=null){
            configMapper.update_cskaoyan_mall_mall_qq(mallConfigBO);
        }
        if (!("").equals(mallConfigBO.getCskaoyanmall_mall_phone()) && mallConfigBO.getCskaoyanmall_mall_phone()!=null){
            configMapper.update_cskaoyan_mall_mall_phone(mallConfigBO);
        }
        if (!("").equals(mallConfigBO.getCskaoyanmall_mall_address()) && mallConfigBO.getCskaoyanmall_mall_address()!=null){
            configMapper.update_cskaoyan_mall_mall_address(mallConfigBO);
        }
    }

    @Override
    public void expressConfig(ExpressConfigBO expressConfigBO) {
        if (!("").equals(expressConfigBO.getCskaoyanmall_express_freight_min()) && expressConfigBO.getCskaoyanmall_express_freight_min()!=null){
            configMapper.update_cskaoyan_mall_express_freight_min(expressConfigBO);
        }
        if (!("").equals(expressConfigBO.getCskaoyanmall_express_freight_value()) && expressConfigBO.getCskaoyanmall_express_freight_value()!=null){
            configMapper.update_cskaoyan_mall_express_freight_value(expressConfigBO);
        }
    }

    @Override
    public void orderConfig(OrderConfigBO orderConfigBO) {
//        if (!orderConfigBO.getCskaoyanmall_order_comment().equals("") && orderConfigBO.getCskaoyanmall_order_comment()!=null){
        if (!("").equals(orderConfigBO.getCskaoyanmall_order_comment()) && orderConfigBO.getCskaoyanmall_order_comment()!=null){
            configMapper.update_cskaoyan_mall_order_comment(orderConfigBO);
        }
//        if (!orderConfigBO.getCskaoyanmall_order_unconfirm().equals("") && orderConfigBO.getCskaoyanmall_order_unconfirm()!=null){
        if (!("").equals(orderConfigBO.getCskaoyanmall_order_unconfirm()) && orderConfigBO.getCskaoyanmall_order_unconfirm()!=null){
            configMapper.update_cskaoyan_mall_order_unconfirm(orderConfigBO);
        }
//        if (!orderConfigBO.getCskaoyanmall_order_unpaid().equals("") && orderConfigBO.getCskaoyanmall_order_unpaid()!=null){
        if (!("").equals(orderConfigBO.getCskaoyanmall_order_unpaid()) && orderConfigBO.getCskaoyanmall_order_unpaid()!=null){
            configMapper.update_cskaoyan_mall_order_unpaid(orderConfigBO);
        }
    }

    @Override
    public void wxConfig(WxConfigBO wxConfigBO) {
        if (!("").equals(wxConfigBO.getCskaoyanmall_wx_catlog_goods()) && wxConfigBO.getCskaoyanmall_wx_catlog_goods()!=null) {
            configMapper.update_cskaoyan_mall_wx_catlog_goods(wxConfigBO);
        }
        if (!("").equals(wxConfigBO.getCskaoyanmall_wx_catlog_list()) && wxConfigBO.getCskaoyanmall_wx_catlog_list()!=null) {
            configMapper.update_cskaoyan_mall_wx_catlog_list(wxConfigBO);
        }
        if (!("").equals(wxConfigBO.getCskaoyanmall_wx_index_brand()) && wxConfigBO.getCskaoyanmall_wx_index_brand()!=null) {
            configMapper.update_cskaoyan_mall_wx_index_brand(wxConfigBO);
        }
        if (!("").equals(wxConfigBO.getCskaoyanmall_wx_index_hot()) && wxConfigBO.getCskaoyanmall_wx_index_hot()!=null) {
            configMapper.update_cskaoyan_mall_wx_index_hot(wxConfigBO);
        }
        if (!("").equals(wxConfigBO.getCskaoyanmall_wx_index_new()) && wxConfigBO.getCskaoyanmall_wx_index_new()!=null) {
            configMapper.update_cskaoyan_mall_wx_index_new(wxConfigBO);
        }
        if (!("").equals(wxConfigBO.getCskaoyanmall_wx_index_topic()) && wxConfigBO.getCskaoyanmall_wx_index_topic()!=null) {
            configMapper.update_cskaoyan_mall_wx_index_topic(wxConfigBO);
        }
        if (!("").equals(wxConfigBO.getCskaoyanmall_wx_share()) && wxConfigBO.getCskaoyanmall_wx_share()!=null) {
            configMapper.update_cskaoyan_mall_wx_share(wxConfigBO);
        }
    }

    @Override
    public QueryMallConfigVO getMall() {
        QueryMallConfigVO queryMallConfigVO = new QueryMallConfigVO();
        String mall = configMapper.query_cskaoyan_mall_mall_name();
        String address = configMapper.query_cskaoyan_mall_mall_address();
        String phone = configMapper.query_cskaoyan_mall_mall_phone();
        String qq = configMapper.query_cskaoyan_mall_mall_qq();
        queryMallConfigVO.setCskaoyanmall_mall_name(mall);
        queryMallConfigVO.setCskaoyanmall_mall_address(address);
        queryMallConfigVO.setCskaoyanmall_mall_phone(phone);
        queryMallConfigVO.setCskaoyanmall_mall_address(qq);

        return queryMallConfigVO;
    }

    @Override
    public QueryExpressConfigVO getExpress() {
        QueryExpressConfigVO queryExpressConfigVO = new QueryExpressConfigVO();
        queryExpressConfigVO.setCskaoyanmall_express_freight_min(configMapper.query_cskaoyan_mall_express_freight_min());
        queryExpressConfigVO.setCskaoyanmall_express_freight_value(configMapper.query_cskaoyan_mall_express_freight_value());
        return queryExpressConfigVO;
    }

    @Override
    public QueryOrderConfigVO getOrder() {
        QueryOrderConfigVO queryOrderConfigVO = new QueryOrderConfigVO();
        queryOrderConfigVO.setCskaoyanmall_order_comment(configMapper.query_cskaoyan_mall_order_comment());
        queryOrderConfigVO.setCskaoyanmall_order_unconfirm(configMapper.query_cskaoyan_mall_order_unconfirm());
        queryOrderConfigVO.setCskaoyanmall_order_unpaid(configMapper.query_cskaoyan_mall_order_unpaid());
        return queryOrderConfigVO;
    }

    @Override
    public QueryWxConfigVO getWx() {
        QueryWxConfigVO queryWxConfigVO = new QueryWxConfigVO();
        queryWxConfigVO.setCskaoyanmall_wx_catlog_goods(configMapper.query_cskaoyan_mall_wx_catlog_goods());
        queryWxConfigVO.setCskaoyanmall_wx_catlog_list(configMapper.query_cskaoyan_mall_wx_catlog_list());
        queryWxConfigVO.setCskaoyanmall_wx_index_brand(configMapper.query_cskaoyan_mall_wx_index_brand());
        queryWxConfigVO.setCskaoyanmall_wx_index_hot(configMapper.query_cskaoyan_mall_wx_index_hot());
        queryWxConfigVO.setCskaoyanmall_wx_index_new(configMapper.query_cskaoyan_mall_wx_index_new());
        queryWxConfigVO.setCskaoyanmall_wx_index_topic(configMapper.query_cskaoyan_mall_wx_index_topic());
        queryWxConfigVO.setCskaoyanmall_wx_share(configMapper.query_cskaoyan_mall_wx_share());
        return queryWxConfigVO;
    }
}
